replace serialize key,value functions by serialize_entry #614
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The purpuse is to serialize serde_json::Map<> with other serializer like serde-xml-rs::to_writer(&mut writer, &json_value) that is not possible today. The problem is serde_json use only map.serialize_key(k) and map.serialize_key(v). Some serializer can use only map.serialize_entry(k, v). If we follow these advices :
https://docs.serde.rs/src/serde/ser/mod.rs.html#1778-1784
/// Serialize a map key.
///
/// If possible,
Serialize
implementations are encouraged to use///
serialize_entry
instead as it may be implemented more efficiently in/// some formats compared to a pair of calls to
serialize_key
and///
serialize_value
.and the implementation of serialize_entry : https://docs.serde.rs/src/serde/ser/mod.rs.html#1798-1826
We should use during the Map serialize use serialize_entry function instead of serialize_key/serialize_key and use them into serialize_entry.